Page({
  data: {
    starCount: 1, // 当前星级数
    progress: 20, // 进度百分比
    stars: [
      { active: true },
      { active: false },
      { active: false },
      { active: false },
      { active: false }
    ]
  },

  onLoad() {
    // 模拟从后台获取用户星级数据
    this.fetchUserData();
  },

  // 从后台获取用户数据
  fetchUserData() {
    // 模拟网络请求
    setTimeout(() => {
      const userData = {
        starCount: 1,
        progress: 20
      };
      
      // 更新星级显示
      const stars = this.data.stars.map((_, index) => {
        return { active: index < userData.starCount };
      });
      
      this.setData({
        starCount: userData.starCount,
        progress: userData.progress,
        stars: stars
      });
    }, 800);
  },

  // 跳转到历史订单页面
  navigateToHistory() {
    wx.navigateTo({
      url: '/pages/order/history'
    });
  },

  // 跳转到修改信息页面
  navigateToEdit() {
    wx.navigateTo({
      url: '/pages/profile/edit'
    });
  },

  // 其他导航功能
  navigateToAddress() {
    wx.navigateTo({
      url: '/pages/address/list'
    });
  },

  navigateToGuide() {
    wx.navigateTo({
      url: '/pages/guide/index'
    });
  },

  navigateToPrivacy() {
    wx.navigateTo({
      url: '/pages/privacy/index'
    });
  },

  navigateToAgreement() {
    wx.navigateTo({
      url: '/pages/agreement/index'
    });
  },

  navigateToRecruit() {
    wx.navigateTo({
      url: '/pages/recruit/index'
    });
  }
});